package xyz.heyaoshare.config.satoken.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.extern.slf4j.Slf4j;
import xyz.heyaoshare.core.entity.system.User;

/**
 * 用户信息上下文
 * @author YueHe
 * @version 0.0.1
 * @since 2025/6/25 上午11:43
 */
@Slf4j
public class UserContextHolder {

    private static final ThreadLocal<User> USER = new TransmittableThreadLocal<>();

    public static User get() {
        return USER.get();
    }

    public static void set(User user) {
        USER.set(user);
    }

    public static void clear() {
        USER.remove();
    }

}